<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>苏仕达 - 功能手套定制专家 防切割手套 耐高温手套</title>
    <meta charset="UTF-8"/>
    <meta http-equiv="X-UA-compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="shortcut icon" type="image/x-icon" href="assets/images/favicon.png"/>
    <link rel="stylesheet" href="assets/css/swap.css" />
    <link rel="stylesheet" href="assets/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="assets/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="assets/css/owl.carousel.min.css"/>
    <link rel="stylesheet" href="assets/css/animate.min.css"/>
    <link rel="stylesheet" href="assets/css/jquery-ui.css"/>
    <link rel="stylesheet" href="assets/css/slick.css"/>
    <link rel="stylesheet" href="assets/css/chosen.min.css"/>
    <link rel="stylesheet" href="assets/css/pe-icon-7-stroke.css"/>
    <link rel="stylesheet" href="assets/css/magnific-popup.min.css"/>
    <link rel="stylesheet" href="assets/css/lightbox.min.css"/>
    <link rel="stylesheet" href="assets/js/fancybox/source/jquery.fancybox.css"/>
    <link rel="stylesheet" href="assets/css/jquery.scrollbar.min.css"/>
    <link rel="stylesheet" href="assets/css/mobile-menu.css"/>
    <link rel="stylesheet" href="assets/fonts/flaticon/flaticon.css"/>
    <link rel="stylesheet" href="assets/css/style.css"/>
</head>
<body class="productsgrid-page">

<header th:replace="head :: html"></header>

<div class="main-content main-content-product left-sidebar">
    <div class="container">
        <div class="row">
            <div class="col-lg-12">
                <div class="breadcrumb-trail breadcrumbs">
                    <ul class="trail-items breadcrumb">
                        <li class="trail-item trail-begin">
                            <a href="index.html">苏仕达手套</a>
                        </li>
                        <li class="trail-item trail-end active">
                            产品列表
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="content-area shop-grid-content no-banner col-lg-9 col-md-9 col-sm-12 col-xs-12">
                <div class="site-main">
                    <h3 class="custom_blog_title">
                        产品列表
                    </h3>
                    <ul class="row list-products auto-clear equal-container product-grid" id="product_list">

                    </ul>
                </div>
            </div>

            <!--左边的内容-->
            <div class="sidebar col-lg-3 col-md-3 col-sm-12 col-xs-12">
                <div class="wrapper-sidebar shop-sidebar">
                    <div class="widget woof_Widget" id="tagInfoWidget">

                        <div class="widget widget-categories">
                            <h3 class="widgettitle">分类</h3>
                            <ul class="list-categories">
                                <li>
                                    <input type="radio" name="type" id="type_all" value="allType" onclick='selectType(this)' checked="checked"/>
                                    <label for="type_all" class="label-text">
                                        所有
                                    </label>
                                </li>
                                <hr />
                                <li>
                                    <input type="radio" name="type" id="hotResistant_all" value="hotResistant_all" onclick='selectType(this)'/>
                                    <label for="hotResistant_all" class="label-text">
                                        耐高温手套
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="hotResistant_knit" value="hotResistant_knit" onclick='selectType(this)' />
                                    <label for="hotResistant_knit" class="label-text">
                                        针织类
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="hotResistant_gumming" value="hotResistant_gumming" onclick='selectType(this)'/>
                                    <label for="hotResistant_gumming" class="label-text">
                                        浸胶类
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="hotResistant_sew" value="hotResistant_sew" onclick='selectType(this)'/>
                                    <label for="hotResistant_sew" class="label-text">
                                        缝制类
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="hotResistant_injection" value="hotResistant_injection" onclick='selectType(this)'/>
                                    <label for="hotResistant_injection" class="label-text">
                                        注塑类
                                    </label>
                                </li>


                                <hr />
                                <li>
                                    <input type="radio" name="type" id="cutResistant_all" value="cutResistant_all" onclick='selectType(this)'/>
                                    <label for="cutResistant_all" class="label-text">
                                        防切割手套
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="cutResistant_pure"  value="cutResistant_pure" onclick='selectType(this)'/>
                                    <label for="cutResistant_pure" class="label-text">
                                        纯手芯
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type"  id="cutResistant_glue" value="cutResistant_glue" onclick='selectType(this)'/>
                                    <label for="cutResistant_glue" class="label-text">
                                        涂胶类
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="cutResistant_steel"  value="cutResistant_steel" onclick='selectType(this)'/>
                                    <label for="cutResistant_steel" class="label-text">
                                        钢环钢丝
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="cutResistant_sew"  value="cutResistant_sew" onclick='selectType(this)'/>
                                    <label for="cutResistant_sew" class="label-text">
                                        缝制类
                                    </label>
                                </li>

                                <hr />

                                <li>
                                    <input type="radio" name="type"  id="hardWearing" value="hardWearing" onclick='selectType(this)'/>
                                    <label for="hardWearing" class="label-text">
                                        耐磨手套
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="antiCollision"  value="antiCollision" onclick='selectType(this)'/>
                                    <label for="antiCollision" class="label-text">
                                        防撞手套
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="coldProtective"  value="coldProtective" onclick='selectType(this)'/>
                                    <label for="coldProtective" class="label-text">
                                        防寒手套
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="antiChemical"  value="antiChemical" onclick='selectType(this)'/>
                                    <label for="antiChemical" class="label-text">
                                        防化手套
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="antiCuttingArm" value="antiCuttingArm" onclick='selectType(this)'/>
                                    <label for="antiCuttingArm" class="label-text">
                                        防割护臂
                                    </label>
                                </li>

                                <li>
                                    <input type="radio" name="type" id="policeUse" value="policeUse" onclick='selectType(this)'/>
                                    <label for="policeUse" class="label-text">
                                        警用手套
                                    </label>
                                </li>

                                <li>
                                    <input type="radio" name="type" id="pet"  value="pet" onclick='selectType(this)'/>
                                    <label for="pet" class="label-text">
                                        宠物手套
                                    </label>
                                </li>

                                <hr />

                                <li>
                                    <input type="radio" name="type" id="otherType" value="otherType" onclick='selectType(this)'/>
                                    <label for="otherType" class="label-text">
                                        其他
                                    </label>
                                </li>


                            </ul>
                        </div>

                        <div th:if=" ${session.user} == 'admin'">
                            <a data-toggle="modal" data-target="#myModal"> 添加 </a>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <form id="editProduct-form">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        添加产品
                    </h4>
                </div>
                <div class="modal-body">


                    <table>
                        <tr>
                            <td>产品名称：<br />
                                <input type="hidden" id="edit_ProductId" name="productId" value="0" />
                                <input type="text" id="edit_ProductName" name="productname" value="" /></td>
                            <td>星星数：<br />
                                <input type="text" id="edit_Productstar" name="productstar" value="5" /></td>
                        </tr>


                        <tr>
                            <td>缩略图：<br /><input type="text" name="thumbnailsPicurl" id="edit_ThumbnailPic" value="" /></td>
                            <td>详细图：<br /><input type="text" name="detailPicurl" id="edit_DetailPic" value="" /></td>
                        </tr>

                        <tr>
                            <td colspan="2">产品属性：<br /><input style="width: 100%" type="text" name="productattribute" id="edit_Productattribute" value="" /></td>
                        </tr>

                        <tr>
                            <td>产品型号：<br /><input type="text" name="modelno" id="edit_Modelno" value="" /></td>
                            <td>尺寸：<br /><input type="text" name="availableSize" id="edit_AvailableSize" value="" /></td>
                        </tr>

                        <tr>
                            <td colspan="2">产品标签：<br /><input style="width: 100%" type="text" name="producttags" id="edit_ProductTags" value="" /></td>
                        </tr>

                        <tr><td colspan="2">产品描述：<textarea id="edit_PorductDesc" name="productdesc" rows="8" cols="30" value="" /></td></tr>
                    </table>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <button type="button" onclick="saveProduct()" class="btn btn-primary">
                        保存
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </form>
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->



<div th:replace="foot :: html"></div>

<script src="assets/js/jquery-1.12.4.min.js"></script>
<script src="assets/js/jquery.plugin-countdown.min.js"></script>
<script src="assets/js/jquery-countdown.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/owl.carousel.min.js"></script>
<script src="assets/js/magnific-popup.min.js"></script>
<script src="assets/js/isotope.min.js"></script>
<script src="assets/js/jquery.scrollbar.min.js"></script>
<script src="assets/js/jquery-ui.min.js"></script>
<script src="assets/js/mobile-menu.js"></script>
<script src="assets/js/chosen.min.js"></script>
<script src="assets/js/slick.js"></script>
<script src="assets/js/jquery.elevateZoom.min.js"></script>
<script src="assets/js/jquery.actual.min.js"></script>
<script src="assets/js/fancybox/source/jquery.fancybox.js"></script>
<script src="assets/js/lightbox.min.js"></script>
<script src="assets/js/owl.thumbs.min.js"></script>
<script src="assets/js/jquery.scrollbar.min.js"></script>
<script src="assets/js/frontend-plugin.js"></script>

<script th:inline="javascript">

    /*<![CDATA[*/
    $(document).ready(function() {

        var tag = getQueryVariable("tag");
        /*if("" == tag){
            tag = "allType";
        }*/
        if(tag != null && "" != tag){
            $("#"+tag+"").prop("checked", "checked");
        }

        loadProduct(tag);

        // loadTagInfo();
    });

    function saveProduct() {


        $.ajax({
            //几个参数需要注意一下
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "/api/product/saveProduct.do" ,//url
            data: $('#editProduct-form').serialize(),
            success: function (message) {
                var result = message;
                alert(result.resultMessage);
                if (result.result) {
                    // 刷新页面
                    window.location.reload();
                }

            },
            error : function() {
                alert("保存异常！");
            }
        });
        // 必须返回false，否则表单会自己再做一次提交操作，并且页面跳转
        return false;
    }


    function loadProduct(tag) {
        $("#product_list").html("");
        $.post("/api/product/searchProduct.do",
                { //需要传入后代的数据
                    tags:tag
                },
                function (message) {
                    var result = message;
                    var productHtml ="";
                    for (var i in result.productinfoList) {

                        productHtml +=
                                '<li class="product-item col-lg-4 col-md-6 col-sm-6 col-xs-6 col-ts-12 style-1">' +
                                '<div class="product-inner equal-element"><div class="product-top"><div class="flash"><span class="onnew"><span class="text">new</span></span></div>' +
                                '</div><div class="product-thumb"><div class="thumb-inner"><a href="productdetails_leftsidebar.html?id='+result.productinfoList[i].id+'">' +
                                '<img src="assets/images/product/productlist/'+result.productinfoList[i].thumbnailspicurl+'" alt="img"/></a><div class="thumb-group">' +
                                '<a href="#" class="button quick-wiew-button" productid="'+result.productinfoList[i].id+'">Quick View</a></div></div></div><div class="product-info">' +
                                '<label  style="color: black">'+ result.productinfoList[i].productname +'</label><div class="group-info">' +
                                '<div class="stars-rating"><div class="star-rating"><span class="star-'+result.productinfoList[i].productstar+'"></span>' +
                                '</div></div><div class="price"><ins>'+result.productinfoList[i].modelno+'</ins></div></div>'
                            +'</div></div></li>';
                    }
                    $("#product_list").html(productHtml);

                }
        );
        // 必须返回false，否则表单会自己再做一次提交操作，并且页面跳转
        return false;
    }



    var tag ="";
    
    function selectType(o) {
        /*第二层*/
        changeParam("tag", $(o).val());
        // 重新加载
        loadProduct(getQueryVariable("tag"));
    }



    function getQueryVariable(variable)
    {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if(pair[0] == variable){return pair[1];}
        }
        return "";
    }



    function changeParam(name, value) {
        var url = window.location.href;
        var newUrl = "";
        var reg = new RegExp("(^|)" + name + "=([^&]*)(|$)");
        var tmp = name + "=" + value;
        if (url.match(reg) != null) {
            newUrl = url.replace(eval(reg), tmp);
        } else {
            if (url.match("[\?]")) {
                newUrl = url + "&" + tmp;
            } else {
                newUrl = url + "?" + tmp;
            }
        }
        history.replaceState(null, null, newUrl);
    }

    /*]]>*/


</script>

</body>
</html>